import {Component, Input, OnInit, ViewChild} from '@angular/core';
import {NzDrawerRef, NzMessageService} from 'ng-zorro-antd';
import {_HttpClient} from '@delon/theme';

@Component({
  selector: 'app-isystem-permission-add',
  templateUrl: './permission-add.component.html',
})
export class IsystemPermissionAddComponent implements OnInit {
  @Input()
  record: any;
  i: any={
  };
  constructor(
    private msgSrv: NzMessageService,
    public http: _HttpClient,
    private ref: NzDrawerRef,
  ) { }

  ngOnInit(): void {
    if (this.record){
      this.i=this.record
    }
    console.log(this.i)
  }
  save() {
    if(this.i.add){
      this.http.post(`sys/permission/add`, this.i).subscribe(res => {
        this.ref.close(true);
      });
    }else {
      this.http.post(`sys/permission/edit`, this.i).subscribe(res => {
        this.ref.close(true);
      });
    }
  }

  cancel() {
    this.ref.close()
  }
}
